import os

if __name__ == '__main__':
    # 加载django项目的配置信息
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "blogproject.settings")
    # 导入django,并启动django项目
    import django

    django.setup()
    from app01.models import Articles, Comment, Moods
    from api.utils.get_addr_info import get_addr_info

    mood_query = Moods.objects.all()
    for obj in mood_query:
        addr = get_addr_info(obj.ip)
        obj.addr = addr
        obj.save()
